<template>
  <div class="mod-tenant__tenant">
    <el-form :inline="true" :model="dataForm" @keyup.enter="getDataList()" style="margin: 10px 0">
      <div hidden>
        <el-form-item>
          <el-input v-model="dataForm.warehouseId"></el-input>
        </el-form-item>
      </div>
      <el-form-item>
        <el-input v-model="dataForm.zoneCode" placeholder="请输入库房编码" clearable></el-input>
      </el-form-item>
      <el-form-item>
        <el-input v-model="dataForm.zoneName" placeholder="请输入库房名称" clearable></el-input>
      </el-form-item>

      <el-form-item>
        <el-button @click="getDataList()">{{ $t("query") }}</el-button>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="addOrUpdateHandle()">{{ $t("add") }}</el-button>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="exportHandle()">{{ $t("export") }}</el-button>
      </el-form-item>
      <el-form-item>
        <el-button type="danger" @click="deleteHandle()">{{ $t("deleteBatch") }}</el-button>
      </el-form-item>
    </el-form>
    <el-table v-loading="dataListLoading" :data="dataList" border @selection-change="dataListSelectionChangeHandle" @sort-change="dataListSortChangeHandle" style="width: 100%">
      <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
      <el-table-column label="库区编码" prop="zoneCode" header-align="center" align="center"></el-table-column>
      <el-table-column label="库区名称" prop="zoneName" header-align="center" align="center"></el-table-column>
      <el-table-column label="全宗编码" prop="tenantCode" header-align="center" align="center"></el-table-column>
      <el-table-column label="密集架范围" prop="createDate" header-align="center" align="center"></el-table-column>
      <el-table-column label="创建时间" prop="createDate" header-align="center" align="center"></el-table-column>
      <el-table-column label="更新人" prop="updater" header-align="center" align="center"></el-table-column>
      <el-table-column label="更新日期" prop="updateDate" header-align="center" align="center"></el-table-column>
      <el-table-column label="备注" prop="description" header-align="center" align="center"></el-table-column>
      <el-table-column label="操作" fixed="right" header-align="center" align="center" width="150">
        <template v-slot="scope">
          <el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">{{ $t("update") }}</el-button>
          <el-button type="text" size="small" @click="deleteHandle(scope.row.id)">{{ $t("delete") }}</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination style="padding: 0px 38%" :current-page="page" :page-sizes="[10, 20, 50, 100]" :page-size="limit" :total="total" layout="total, sizes, prev, pager, next, jumper" @size-change="pageSizeChangeHandle" @current-change="pageCurrentChangeHandle"> </el-pagination>
    <!-- 弹窗, 新增 / 修改 -->
    <reservoir-area-add v-if="addOrUpdateVisible" :warehouseIdArea="warehouseIdArea" ref="addOrUpdate" @refreshDataList="getDataList"></reservoir-area-add>

  </div>
</template>

<script lang="ts">
import useView from "@/hooks/useView";
import { defineComponent, reactive, toRefs } from "vue";
import reservoirAreaAdd from "./reservoir-area-add.vue";
import { IObject } from "@/types/interface";

export default defineComponent({
  components: {
    reservoirAreaAdd
  },
  props: { warehouseIdArea: String },
  setup() {
    const state = reactive({
      getDataListURL: "/archive/warehouse-zone/page",
      getDataListIsPage: true,
      deleteURL: "/archive/warehouse-zone",
      deleteIsBatch: true,
      listVisible: false,
      warehouseId: "",
      exportURL: "/archive/info",
      dataForm: {
        zoneCode: "",
        zoneName: "",
        warehouseId: ""
      }
    });

    return { ...useView(state), ...toRefs(state) };
  },
  watch: {
    warehouseIdArea() {
      this.dataForm.warehouseId = this.warehouseIdArea as string;
      this.getDataList();
    }
  },

  methods: {
    showList(row: IObject) {
      (this.listVisible = true), (this.warehouseId = row.id);
    }
  }
});
</script>
<style lang="less"></style>
